using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Regions;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects 
{
	public static class BO_Regions
	{
		public static DataTable SelectAll(int status)
		{
			try
			{
				BORegions_Select_All action = new BORegions_Select_All();
				usp_Regions_Select_All entity = new usp_Regions_Select_All();
				entity.STATUS = status;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static DataTable SelectTop(int rows, int status)
		{
			try
			{
				BORegions_Select_Top action = new BORegions_Select_Top();
				usp_Regions_Select_Top entity = new usp_Regions_Select_Top();
				entity.NUMBERRECORD = rows;
				entity.STATUS = status;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static DataTable Search(int  region_id)
		{
			try
			{
				BORegions_Search action = new BORegions_Search();
				usp_Regions_Search entity = new usp_Regions_Search();
				entity.REGION_ID = region_id;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
        public static DataTable SelectNodeByParentId(int parent_id)
        {
            try
            {
                BORegions_SelectNode_ByParentId action = new BORegions_SelectNode_ByParentId();
                usp_Regions_SelectNode_ByParentId entity = new usp_Regions_SelectNode_ByParentId();
                entity.PARENT_ID = parent_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string CountChildNode(int region_id)
        {
            try
            {
                BORegions_SelectChildNode_ByRegionId action = new BORegions_SelectChildNode_ByRegionId();
                usp_Regions_SelectChildNode_ByRegionId entity = new usp_Regions_SelectChildNode_ByRegionId();
                entity.REGION_ID = region_id;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
		{
			try
			{
				BORegions_Select_WithPaged action = new BORegions_Select_WithPaged ();
				usp_Regions_Select_WithPaged entity = new usp_Regions_Select_WithPaged ();
				entity.STARTINDEX = startIndex;
				entity.MAXRECORDS = pageCount;
				entity.STATUS = status;
				return action.ExecuteAndReturnDataTable(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static string Insert( int parent_id, string region_name_vn, string region_name_eng, int sort_display, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
		{
			try
			{
				BORegions_Insert action = new BORegions_Insert();
				usp_Regions_Insert entity = new usp_Regions_Insert();
               entity.PARENT_ID = parent_id;
               entity.REGION_NAME_VN = region_name_vn;
               entity.REGION_NAME_ENG = region_name_eng;
               entity.SORT_DISPLAY = sort_display;
               entity.CREATED_DATE = created_date;
               entity.CREATED_BY = created_by;
               entity.MODIFY_DATE = modify_date;
               entity.MODIFY_BY = modify_by;
               entity.STATUS = status;
				return action.ExecuteAndReturnStringValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static string Update( int region_id, int parent_id, string region_name_vn, string region_name_eng, int sort_display, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
		{
			try
			{
				BORegions_Update action = new BORegions_Update();
				usp_Regions_Update entity = new usp_Regions_Update();
               entity.REGION_ID = region_id;
               entity.PARENT_ID = parent_id;
               entity.REGION_NAME_VN = region_name_vn;
               entity.REGION_NAME_ENG = region_name_eng;
               entity.SORT_DISPLAY = sort_display;
               entity.CREATED_DATE = created_date;
               entity.CREATED_BY = created_by;
               entity.MODIFY_DATE = modify_date;
               entity.MODIFY_BY = modify_by;
               entity.STATUS = status;
				return action.ExecuteAndReturnStringValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static bool Delete(int region_id)
		{
			try
			{
				BORegions_Delete action = new BORegions_Delete();
				usp_Regions_Delete entity = new usp_Regions_Delete();
				entity.REGION_ID = region_id;
				return action.ExecuteAndReturnBooleanValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public static bool Restore(int region_id)
		{
			try
			{
				BORegions_Restore action = new BORegions_Restore();
				usp_Regions_Restore entity = new usp_Regions_Restore();
				entity.REGION_ID = region_id;
				return action.ExecuteAndReturnBooleanValue(entity);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
        public static DataTable SearchByParent(int region_id)
        {
            try
            {
                BORegion_Search_By_Parent action = new BORegion_Search_By_Parent();
                usp_Region_Search_By_Parent entity = new usp_Region_Search_By_Parent();
                entity.REGION_ID = region_id;
                
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchTopByParent(int region_id,int count)
        {
            try
            {
                BORegion_Search_Top_By_Parent action = new BORegion_Search_Top_By_Parent();
                usp_Region_Search_Top_By_Parent entity = new usp_Region_Search_Top_By_Parent();
                entity.REGION_ID = region_id;
                entity.NUMBERRECORD = count;
                
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchByName(string region_name)
        {
            try
            {
                BORegions_Search_By_Name action = new BORegions_Search_By_Name();
                usp_Regions_Search_By_Name entity = new usp_Regions_Search_By_Name();
                entity.REGION_NAME_ENG = region_name;
                
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
	}
}

